Object: outputfield

The outputfield object is a custom type for use in Python scripts to represent an output field.

NOTE:

The name, value, quality, and timestamp properties of an output field are "read only". Attempting to write directly to these properties generates a runtime error.

However, the value, quality, and timestamp properties of an output field can be written to with "set" methods.

Properties

 

Name

Data type

Description

value

int/double/string

The value of the field.

timestamp

datetime.datetime

The timestamp of the field.

See the Important notes on field timestamps topic for details on timestamp format as well as upper and lower bounds on the timestamp.

quality

int

The quality of the field.

name

string

The name of the field.

Methods

 

Name

Return data type

Description

is_quality_good()

boolean

Returns True if the output field quality is good. Otherwise, returns False.

is_quality_bad()

boolean

Returns True if the output field quality is bad. Otherwise, returns False.

set_quality_good()

void

Sets the output field quality to good.

set_quality_bad()

void

Sets the output field quality to bad.

set_timestamp(timestamp)

void

Sets the output field timestamp, using a timestamp parameter. The parameter must be of type datetime.datetime. See the Important notes on field timestamps topic for details on timestamp format as well as upper and lower bounds on the timestamp.

set( inputfield | outputfield | value [, timestamp [, quality]] )

void

The set() method parameters can be any ONE of the following:

  • inputfield

  • outputfield

  • value (and, optionally, timestamp and quality)

    In this case:

    • The value parameter is required and must be one of the following types: int/double/string. Ensure that the type of the value you are assigning matches the type specified when configuring the block output field.

    • For double fields, the value set must be a floating point value. Use the Python float(x) built-in function to convert to a floating point value.

    • For integer fields, the value set must be an integer value. Use the Python int(x) built-in function to convert to an integer value.

    • For string fields, the value set must be a string value. Use the Python str(x) built-in function to convert to a string value.

    • The timestamp parameter is optional and must be of type datetime.datetime. If it is not specified, execute time is used. See the Important notes on field timestamps topic for details on timestamp format as well as upper and lower bounds on the timestamp.

    • The quality parameter is optional and must be of type int. If it is not specified, good quality is used.

Accessing output fields

Output fields must be accessed via the outputs container.

Examples

The following examples illustrate checking output field quality.

Python:

if inputs.MyInputField.is_quality_good():

    # Take action because of good quality...

 

#or

 

if inputs.MyInputField.is_quality_bad():

    # Take action because of bad quality...

 

 

The following examples illustrate several ways of using the set method on output fields.

Python:

outputs.MyOutputField.set( 123.456 )

 

#or

 

outputs.MyOutputField.set( 123.456, now() )

 

#or

 

outputs.MyOutputField.set( inputs.MyInputField.value, inputs.MyInputField.timestamp, inputs.MyInputField.quality)

 

#or

 

outputs.MyOutputField.set( inputs.MyInputField )

 

 


Related topics:

  

CSense 2023- Last updated: June 24,2025